//
//  ASIHTTPConnection.h
//  Growth_iPhone
//
//  Created by Steven on 8/8/12.
//  Copyright (c) 2012 MEET Studio. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "HB+ASIHTTPRequest.h"

#import "ASIDownloadCache.h"

@protocol ASIHTTPConnectionDelegate;
@class ASIHTTPRequest;
@interface ASIHTTPConnection : NSObject
{
    ASIHTTPRequest *request;
    BOOL isResultDict;          //Default YES，返回结果是否为Dict
}

@property (assign) id<ASIHTTPConnectionDelegate> connectionDelegate; 

@property (nonatomic, retain) ASIHTTPRequest *request;
@property (nonatomic) BOOL isResultDict;

//初始化方法
- (id)initGETWithURL:(NSURL *)newURL;
- (id)initGETWithURL:(NSURL *)newURL resultDict:(BOOL)resultDict;
- (id)initGETWithURL:(NSURL *)newURL resultDict:(BOOL)resultDict isCache:(BOOL)isCache;

- (id)initPOSTWithURL:(NSURL *)newURL jsonData:(NSData *)jsonData;
- (id)initPOSTWithURL:(NSURL *)error jsonData:(NSData *)jsonData resultDict:(BOOL)resultDict;

//开始网络请求
- (BOOL)start;
- (BOOL)startAsynchronous;
- (BOOL)startSynchronous;


@end


@protocol ASIHTTPConnectionDelegate <NSObject>
@optional 

- (void)requestFinished:(ASIHTTPConnection *)connection resultDict:(NSDictionary *)dict URL:(NSURL *)url info:(NSDictionary *)info;
- (void)requestFailed:(ASIHTTPConnection *)connection error:(NSError *)error URL:(NSURL *)url info :(NSDictionary *)info;
@end